<!DOCTYPE html>
<html lang="en">

<head>
   <meta charset="UTF-8">
   <title>update</title>
   <script>
      function update() {
         if (uid.value.length == 0) {
            alert("id不能为空");
            return;
         }
         var xhr = new XMLHttpRequest();
         xhr.onreadystatechange = function () {
            if (xhr.status == 200 && xhr.readyState == 4) {
               var result = xhr.responseText;
               console.log(result)
               if (result == 1) {
                  alert("修改成功")
               } else {
                  alert("修改失败")
               }
            }
         }
         var url = "http://localhost:8080/user/v1/updateUser";
         xhr.open("put", url, true);
         xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
         var formdata = "uid=" + uid.value + "&email=" + email.value +
            "&phone=" + phone.value + "&gender=" + gender.value;
         xhr.send(formdata);
      }
   </script>
</head>

<body>

   <fieldset>
      <legend>用户修改</legend>
      <p>
         ID&emsp; <input type="text" id="uid">
      </p>
      <p>
         邮箱 <input type="text" id="email">
      </p>
      <p>
         电话 <input type="text" id="phone">
      </p>
      <p>
         性别 <input type="text" id="gender">
      </p>
      <button onclick="update()">提交</button>

   </fieldset>


</body>

</html>